#include "StartScene.h"
#include "MainScene.h"
#include "../Base/VisibleRect.h"
#include "CustomTool.h"

bool StartScene::init()
{
	if(!Layer::init())
		return false;
	log("StartLayer::init");

	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Brave/image/role.plist","Brave/image/role.pvr.ccz");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Brave/image/ui.plist","Brave/image/ui.pvr.ccz");
	auto background = Sprite::create("Brave/image/start-bg.jpg");
	background->setPosition(VisibleRect::center());
	this->addChild(background);

	auto item = CustomTool::createMenuItemImage("start1.png", "start2.png", CC_CALLBACK_1(StartScene::onStart,this));
	auto menu = Menu::createWithItem(item);
	this->addChild(menu);
	return true;
}


Scene* StartScene::createScene()
{
    auto scene = Scene::create();   
    auto layer = StartScene::create();
    scene->addChild(layer);
    return scene;
}


void StartScene::onStart(Ref* obj)
{
	log("StartLayer::onStart");
	auto scene = MainScene::createScene();
	Director::getInstance()->replaceScene(scene);
}